package cn.livingCloud.dto;

import cn.livingCloud.entity.system.ImageResource;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by sujiantang on 2015/12/21.
 */
public class ImageUploadDto extends JsonDto {
    //    {"original":"demo.jpg","name":"demo.jpg","url":"\/server\/ueditor\/upload\/image\/demo.jpg","size":"99697","type":".jpg","state":"SUCCESS"}
    private MultipartFile imageFile;

    private String original;
    private String name;
    private String url;
    private long size;
    private String type;
    private String state;

    public ImageUploadDto() {
    }

    public void load(ImageResource resource) {
        this.imageFile = null;
        this.original = resource.getOriginalFileName();
        this.name = resource.getOriginalFileName();
        this.url = resource.getUuid();
        this.size = resource.getFileByte().length;
        this.type = resource.getExtName();
        this.state = "SUCCESS";
    }

    public MultipartFile getImageFile() {
        return imageFile;
    }

    public ImageUploadDto setImageFile(MultipartFile imageFile) {
        this.imageFile = imageFile;
        return this;
    }

    public String getOriginal() {
        return original;
    }

    public ImageUploadDto setOriginal(String original) {
        this.original = original;
        return this;
    }

    public String getName() {
        return name;
    }

    public ImageUploadDto setName(String name) {
        this.name = name;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public ImageUploadDto setUrl(String url) {
        this.url = url;
        return this;
    }

    public long getSize() {
        return size;
    }

    public ImageUploadDto setSize(long size) {
        this.size = size;
        return this;
    }

    public String getType() {
        return type;
    }

    public ImageUploadDto setType(String type) {
        this.type = type;
        return this;
    }

    public String getState() {
        return state;
    }

    public ImageUploadDto setState(String state) {
        this.state = state;
        return this;
    }
}
